package enums;

import lombok.extern.slf4j.Slf4j;

import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.Set;
import java.util.TreeSet;

enum Explore { HERE, THERE }

@Slf4j
public class Reflection {

    public static Set<String> analyze(Class<?> enumClass){
        log.info("______Analyzing " + enumClass +"_________");
        log.info("Interfaces:");
        for(Type t : enumClass.getGenericInterfaces())
            log.info(String.valueOf(t));
        log.info(
            "Base: " + enumClass.getSuperclass());
        log.info("Methods: ");
        Set<String> methods = new TreeSet<>();
        for(Method m : enumClass.getMethods())
            methods.add(m.getName());
        log.info(String.valueOf(methods));
        return methods;

    }

    public static void main(String[] args) {
        Set<String> exploreMethods =
            analyze(Explore.class);
        Set<String> enumMethods = analyze(Enum.class);
        log.info(
            "Explore.containsAll(Enum)? " +
            exploreMethods.containsAll(enumMethods));
        log.info("Explore.removeAll(Enum): ");
        exploreMethods.removeAll(enumMethods);
        log.info(String.valueOf(exploreMethods));
        //decompile
//        Compiled from "Reflection.java"
//        final class enums.Explore extends java.lang.Enum<enums.Explore> {
//            public static final enums.Explore HERE;
//            public static final enums.Explore THERE;
//            public static enums.Explore[] values();
//            public static enums.Explore valueOf(java.lang.String);
//            static {};
//        }

    }

}
